package com.zz.load.servlet;

import com.zz.load.config.MyServletConfig;
import com.zz.load.exception.MyServletException;
import com.zz.load.http.MyRequestServlet;
import com.zz.load.http.MyResponseServlet;
import java.io.IOException;

public class MyHttpServlet implements MyServlet{
    @Override
    public void init(MyServletConfig servletConfig) throws MyServletException {
        System.out.println("init..." + servletConfig.getInfo());
    }

    @Override
    public void service(MyRequestServlet request, MyResponseServlet response) throws MyServletException, IOException {
        String method = request.getMethod();
        if("get".equalsIgnoreCase(method)){
            doGet(request,response);
        }else if("post".equalsIgnoreCase(method)){
            doPost(request, response);
        }
    }

    @Override
    public void destroy() {
        System.out.println("destory...");
    }

    protected void doPost(MyRequestServlet request, MyResponseServlet response) throws MyServletException, IOException {
        System.out.println("doPost...");
    }

    protected void doGet(MyRequestServlet request, MyResponseServlet response) throws MyServletException, IOException {
        System.out.println("doGet...");
    }
}
